:root {
  --ink: #e8f1f4;
  --muted: #8aa0ab;
  --bg: #071018;
  --panel: #0d1a22;
  --line: rgba(94, 200, 255, 0.22);
  --teal: #2fd3c8;
  --crimson: #e23d2f;
  --gold: #f0b429;
  --city-accent: var(--teal);
  --font-display: 'ZCOOL XiaoWei', 'Noto Sans SC', serif;
  --font-body: 'Noto Sans SC', system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(226, 61, 47, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(47, 211, 200, 0.14), transparent 50%),
    var(--bg);
}

#app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(16px + var(--safe-bottom));
  /* 仅裁切横向，避免模板下拉被 overflow:hidden 直接裁掉 */
  overflow-x: hidden;
  overflow-y: visible;
}

.bg-noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.view {
  display: none;
  padding: 16px;
  animation: fadeIn 0.35s ease;
  overflow: visible;
}

.view.active {
  display: block;
  position: relative;
  z-index: 1;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  text-transform: uppercase;
}

h1 {
  margin: 8px 0 6px;
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  background: linear-gradient(120deg, #fff 20%, var(--teal) 55%, var(--crimson));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.hero-stage {
  position: relative;
  margin: 18px auto 8px;
  width: min(100%, 320px);
  aspect-ratio: 3 / 4;
}

.hero-art {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 40px rgba(47, 211, 200, 0.25));
}

.hero-glow {
  position: absolute;
  inset: 18% 10% 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 211, 200, 0.35), transparent 70%);
  filter: blur(18px);
  animation: pulse 3.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

.home-actions {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 14px 0 0;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  color: #041016;
  background: linear-gradient(120deg, var(--teal), #7af0e5);
  box-shadow: 0 10px 28px rgba(47, 211, 200, 0.28);
}

.btn.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.topbar-brand {
  min-width: 0;
}

.topbar-brand h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
}

.topbar.overlay {
  position: absolute;
  z-index: 5;
  left: 12px;
  right: 12px;
  top: 12px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(7, 16, 24, 0.72);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
}

.topbar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
}

.sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.icon-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 12px;
  height: 42px;
  min-width: 42px;
  width: 42px;
  padding: 0;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.text-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 12px;
  height: 40px;
  min-width: 4.2em;
  width: auto;
  max-width: none;
  padding: 0 16px;
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  font-stretch: normal;
  letter-spacing: 0.18em;
  text-indent: 0.18em; /* 视觉上抵消 letter-spacing 右侧空白 */
  line-height: 1.2;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  word-break: keep-all;
  transform: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  justify-self: end;
  box-sizing: border-box;
}

#btn-cert-save {
  min-width: 4.5em;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--city-accent) 25%, transparent);
  color: var(--city-accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.city-grid {
  display: grid;
  gap: 12px;
}

.city-card {
  position: relative;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.city-card:active {
  transform: scale(0.98);
}

.city-card img {
  width: 112px;
  height: 112px;
  object-fit: cover;
}

.city-card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 12px 14px;
}

.city-card-body strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
}

.city-card-body span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.city-card-body em {
  font-style: normal;
  color: var(--accent, var(--teal));
  font-size: 0.78rem;
  font-weight: 700;
}

.bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin: 4px 0;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent, var(--teal)), #fff6);
}

#view-city {
  position: relative;
  padding: 0;
  min-height: 100dvh;
}

.city-scene {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
}

.city-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.1) contrast(1.05);
}

.city-scene::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 16, 24, 0.55), transparent 28%, rgba(7, 16, 24, 0.72) 100%),
    radial-gradient(circle at 70% 80%, color-mix(in srgb, var(--city-accent) 25%, transparent), transparent 45%);
}

.city-hero {
  position: absolute;
  z-index: 2;
  left: 4%;
  bottom: 8%;
  width: 38%;
  max-width: 180px;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.55));
  animation: bob 4s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.spots {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.spot {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  padding: 0;
}

.spot-pulse {
  display: block;
  width: 18px;
  height: 18px;
  margin: 0 auto 6px;
  border-radius: 50%;
  background: var(--city-accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--city-accent) 70%, transparent);
  animation: ping 1.8s ease-out infinite;
}

.spot.done .spot-pulse {
  background: #9fe870;
  animation: none;
  box-shadow: 0 0 0 4px rgba(159, 232, 112, 0.25);
}

@keyframes ping {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--city-accent) 65%, transparent);
  }
  70% {
    box-shadow: 0 0 0 16px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.spot-label {
  display: inline-block;
  max-width: 110px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(7, 16, 24, 0.78);
  border: 1px solid color-mix(in srgb, var(--city-accent) 45%, transparent);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scene-tip {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: calc(18px + var(--safe-bottom));
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.85rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.passport {
  display: grid;
  gap: 12px;
}

.pass-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--panel);
}

.pass-head {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  padding: 12px;
}

.pass-head img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 12px;
}

.pass-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
}

.pass-head p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.pass-head em {
  font-style: normal;
  color: var(--accent, var(--teal));
  font-weight: 700;
  font-size: 0.8rem;
}

.stamp-row {
  list-style: none;
  margin: 0;
  padding: 0 12px 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stamp-row li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.28;
  filter: grayscale(1);
}

.stamp-row li.on {
  opacity: 1;
  filter: none;
}

.stamp-row img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.stamp-row span {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
}

.modal[hidden] {
  display: none !important;
}

.modal-card {
  width: min(100%, 360px);
  padding: 22px 18px 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, #12222c, #0b151c);
  border: 1px solid var(--line);
  text-align: center;
  animation: pop 0.35s ease;
}

@keyframes pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.stamp-art {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin-bottom: 8px;
  animation: spinIn 0.7s ease;
}

@keyframes spinIn {
  from {
    transform: rotate(-18deg) scale(0.6);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.modal-card h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
}

.modal-card p {
  margin: 0 0 16px;
  color: var(--muted);
  white-space: pre-line;
  line-height: 1.55;
  font-size: 0.9rem;
}

@media (min-width: 640px) {
  #app {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.35);
  }
}

/* —— 通行证入口 —— */
.passport-actions {
  margin: 0 0 12px;
}

.btn.slim {
  padding: 10px 14px;
  font-size: 0.92rem;
  width: 100%;
}

/* —— 奖状制作（传统横版） —— */
.cert-toolbar {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 10px;
  margin-bottom: 12px;
  position: relative;
  z-index: 40;
  overflow: visible;
}

.cert-field {
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  overflow: visible;
}

.cert-field input[type='color'].cert-color-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  padding: 0;
  margin: 0;
  border: 0;
  min-height: 0;
}

/* 金饰色选择（与模板下拉同系） */
.cert-color {
  position: relative;
  z-index: 45;
  overflow: visible;
}

.cert-color-trigger {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(47, 211, 200, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cert-color-trigger:hover,
.cert-color.is-open .cert-color-trigger {
  border-color: rgba(47, 211, 200, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(47, 211, 200, 0.18),
    0 10px 24px rgba(0, 0, 0, 0.28);
}

.cert-color.is-open .cert-select-chevron {
  transform: rotate(225deg) translateY(-2px);
}

.cert-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.25),
    0 0 12px rgba(240, 180, 41, 0.35);
  flex-shrink: 0;
}

.cert-color-meta {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.cert-color-meta strong {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cert-color-meta em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.cert-color-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  margin: 0;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(47, 211, 200, 0.35);
  background: linear-gradient(180deg, #12242e, #0a141c);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(240, 180, 41, 0.08);
  z-index: 60;
  animation: cert-select-in 0.18s ease-out;
}

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

.cert-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.cert-color-option {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.cert-color-option:hover,
.cert-color-option:focus-visible {
  outline: none;
  transform: translateY(-1px) scale(1.04);
  border-color: rgba(47, 211, 200, 0.7);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.cert-color-option.is-active {
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px rgba(240, 180, 41, 0.35),
    0 6px 14px rgba(0, 0, 0, 0.3);
}

.cert-color-option.is-active::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.35);
}

.cert-color-custom {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed rgba(47, 211, 200, 0.35);
  border-radius: 10px;
  background: rgba(47, 211, 200, 0.06);
  color: var(--ink);
  font: inherit;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-align: left;
  cursor: pointer;
}

.cert-color-custom:hover,
.cert-color-custom:focus-visible {
  outline: none;
  border-style: solid;
  background: rgba(47, 211, 200, 0.12);
}

.cert-color-custom-mark {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background:
    conic-gradient(
      from 0deg,
      #e23d2f,
      #f0b429,
      #2fd3c8,
      #5ec8ff,
      #e23d2f
    );
  box-shadow: inset 0 0 0 2px #0a141c;
}

/* 自定义模板下拉（国风朋克） */
.cert-select {
  position: relative;
  z-index: 50;
  overflow: visible;
}

.cert-select-trigger {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(47, 211, 200, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cert-select-trigger:hover,
.cert-select.is-open .cert-select-trigger {
  border-color: color-mix(in srgb, var(--teal) 55%, var(--line));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px color-mix(in srgb, var(--teal) 18%, transparent),
    0 10px 24px rgba(0, 0, 0, 0.28);
}

.cert-select-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c8, var(--gold) 55%, #a86b00);
  box-shadow: 0 0 10px rgba(240, 180, 41, 0.55);
  flex-shrink: 0;
}

.cert-select-label {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cert-select-chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid color-mix(in srgb, var(--teal) 80%, #fff);
  border-bottom: 2px solid color-mix(in srgb, var(--teal) 80%, #fff);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.22s ease;
  opacity: 0.9;
}

.cert-select.is-open .cert-select-chevron {
  transform: rotate(225deg) translateY(-2px);
}

.cert-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 14px;
  border: 1px solid rgba(47, 211, 200, 0.35);
  background: #0f1c24;
  background: linear-gradient(180deg, #12242e, #0a141c);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(240, 180, 41, 0.08);
  max-height: min(280px, 50vh);
  overflow: auto;
  z-index: 200;
  -webkit-overflow-scrolling: touch;
  display: none;
}

.cert-select.is-open .cert-select-menu,
.cert-select-menu.is-open {
  display: block;
  animation: cert-select-in 0.18s ease-out;
}

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

@keyframes cert-select-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.cert-select-option {
  position: relative;
  display: grid;
  grid-template-columns: 16px 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.cert-select-option::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--teal) 55%, transparent);
  background: transparent;
  box-shadow: none;
}

.cert-select-option:hover,
.cert-select-option:focus-visible {
  outline: none;
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  color: #e9fffc;
}

.cert-select-option.is-active {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--gold) 16%, transparent), transparent 70%),
    color-mix(in srgb, var(--teal) 10%, transparent);
  color: #fff8e0;
}

.cert-select-option.is-active::before {
  border-color: var(--gold);
  background: radial-gradient(circle at 35% 30%, #fff6c8, var(--gold));
  box-shadow: 0 0 8px rgba(240, 180, 41, 0.55);
}

.cert-stage {
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  overflow-x: auto;
  padding: 4px 0 8px;
}

.cert-sheet {
  --cert-accent: #d4a017;
  --cert-red: #9b1b1b;
  --cert-ink: #1a120c;
  --cert-paper: #f7ecd6;
  width: min(100%, 520px);
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  color: var(--cert-ink);
}

.cert-paper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.55), transparent 55%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(160, 120, 60, 0.03) 2px,
      rgba(160, 120, 60, 0.03) 3px
    ),
    linear-gradient(165deg, #fff8e8 0%, var(--cert-paper) 40%, #efe0c0 100%);
}

.cert-border-outer,
.cert-border-inner {
  position: absolute;
  pointer-events: none;
  border-radius: 2px;
}

.cert-border-outer {
  inset: 10px;
  border: 2px solid #c62828;
}

.cert-border-inner {
  inset: 16px;
  border: 1.5px solid #b71c1c;
}

.cert-corners {
  position: absolute;
  inset: 18px;
  pointer-events: none;
  z-index: 8;
}

.cert-corner {
  position: absolute;
  width: 56px;
  height: 56px;
  color: var(--cert-accent);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.35));
}

.cert-corner.tl { top: 0; left: 0; }
.cert-corner.tr { top: 0; right: 0; }
.cert-corner.bl { bottom: 0; left: 0; }
.cert-corner.br { bottom: 0; right: 0; }

.cert-crest {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: min(40%, 180px);
  z-index: 9;
  pointer-events: none;
  color: var(--cert-accent);
}

.cert-crest-svg {
  display: block;
  width: 100%;
  height: auto;
  color: var(--cert-accent);
}

.cert-crest-svg .crest-gold-mid {
  stop-color: var(--cert-accent);
}

.cert-logo-disc {
  position: absolute;
  left: 50%;
  top: 46.5%;
  transform: translate(-50%, -50%);
  width: 28%;
  min-width: 36px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: #fff8e8;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--cert-accent) 55%, transparent);
  z-index: 6;
  color: var(--cert-accent);
}

.cert-logo-default,
.cert-logo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.cert-logo {
  object-fit: contain;
  object-position: center;
  background: #fff8e8;
  z-index: 2;
}

.cert-logo-default {
  z-index: 1;
}

.cert-logo-disc .is-hidden,
.cert-logo[hidden],
.cert-logo-default[hidden] {
  display: none !important;
}

.cert-logo-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.cert-file {
  position: relative;
}

.cert-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.cert-file-trigger {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(47, 211, 200, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cert-file-trigger:hover,
.cert-file-trigger:focus-visible {
  outline: none;
  border-color: rgba(47, 211, 200, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(47, 211, 200, 0.18),
    0 10px 24px rgba(0, 0, 0, 0.28);
}

.cert-file.has-file .cert-file-trigger {
  border-color: rgba(240, 180, 41, 0.45);
  background:
    linear-gradient(90deg, rgba(240, 180, 41, 0.12), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.cert-file-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 246, 200, 0.9), transparent 42%),
    linear-gradient(145deg, rgba(47, 211, 200, 0.35), rgba(47, 211, 200, 0.08));
  border: 1px solid rgba(47, 211, 200, 0.35);
  position: relative;
  flex-shrink: 0;
}

.cert-file-icon::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  width: 12px;
  height: 9px;
  border: 1.5px solid rgba(232, 241, 244, 0.9);
  border-radius: 2px;
  box-shadow: 0 -3px 0 -1px rgba(232, 241, 244, 0.55);
}

.cert-file-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.cert-file-text strong {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cert-file-text em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cert-file-action {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(47, 211, 200, 0.35);
  background: rgba(47, 211, 200, 0.12);
  color: #9ff5ee;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.cert-logo-bar .btn.slim {
  width: auto;
  white-space: nowrap;
  height: 48px;
  align-self: end;
}

.cert-content {
  position: relative;
  z-index: 4;
  height: 100%;
  box-sizing: border-box;
  padding: 72px 44px 52px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.cert-editable {
  margin: 0;
  outline: none;
  border-radius: 4px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  max-width: 100%;
  word-break: break-word;
}

.cert-editable:focus,
.cert-editable.editing {
  background: rgba(198, 40, 40, 0.06);
  box-shadow: 0 0 0 1px rgba(198, 40, 40, 0.35);
}

.cert-sheet.cert-exporting {
  box-shadow: none !important;
  border-radius: 0 !important;
}

.cert-sheet.cert-exporting .cert-editable:focus,
.cert-sheet.cert-exporting .cert-editable.editing {
  background: transparent !important;
  box-shadow: none !important;
}

.cert-title {
  flex-shrink: 0;
  text-align: center;
  font-size: clamp(1.45rem, 5.5vw, 2.2rem);
  font-weight: 700;
  color: var(--cert-red);
  letter-spacing: 0.45em;
  text-indent: 0.45em;
  line-height: 1;
  margin: 0 0 6px;
  white-space: nowrap; /* 防止「奖」「状」被字距挤成上下两行 */
}

.cert-recipient {
  flex-shrink: 0;
  margin: 0 0 4px;
  padding-left: 4%;
  font-size: clamp(0.85rem, 2.8vw, 1.05rem);
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.cert-name {
  display: inline-block;
  min-width: 3.2em;
  border-bottom: 1px solid rgba(26, 18, 12, 0.45);
  text-align: center;
  padding: 0 6px 2px;
  font-weight: 600;
}

.cert-suffix {
  flex-shrink: 0;
}

.cert-body-block {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  padding: 0 6% 0 8%;
  font-size: clamp(0.72rem, 2.3vw, 0.9rem);
  line-height: 1.55;
  overflow: hidden;
}

.cert-body {
  text-align: justify;
  text-indent: 2em;
  flex: 0 1 auto;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
}

.cert-award-line {
  flex: 0 0 auto;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  margin: 0;
  text-align: center;
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25em 0.4em;
  box-sizing: border-box;
}

.cert-award-prefix {
  flex: 0 0 auto;
  font-size: 0.95em;
}

.cert-honor {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  font-size: clamp(0.95rem, 3.2vw, 1.25rem);
  font-weight: 700;
  color: var(--cert-ink);
  letter-spacing: 0.08em;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.cert-closing {
  flex: 0 0 auto;
  min-width: 0;
  margin: 2px 0 0;
  text-indent: 2em;
}

.cert-footer {
  position: absolute;
  right: 74px;
  bottom: 52px;
  left: 44px;
  margin: 0;
  padding: 0;
  text-align: right;
  font-size: clamp(0.7rem, 2.2vw, 0.86rem);
  line-height: 1.55;
  display: grid;
  gap: 1px;
  justify-items: end;
  pointer-events: none;
  z-index: 5;
}

.cert-footer .cert-editable {
  pointer-events: auto;
}

.cert-issuer,
.cert-date {
  min-width: 8em;
}

.cert-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.cert-form label {
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.cert-form input,
.cert-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}

.cert-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding-bottom: 8px;
}

@media (max-width: 420px) {
  .cert-crest {
    top: 2px;
    width: min(36%, 140px);
  }

  .cert-logo-disc {
    width: 26%;
    min-width: 30px;
  }

  .cert-content {
    padding: 54px 22px 48px;
  }

  .cert-title {
    font-size: clamp(1.2rem, 6.2vw, 1.55rem);
    letter-spacing: 0.28em;
    text-indent: 0.28em;
    line-height: 1;
    margin: 0 0 4px;
    white-space: nowrap;
  }

  .cert-recipient {
    margin: 0 0 2px;
    font-size: clamp(0.78rem, 3.2vw, 0.92rem);
  }

  .cert-footer {
    right: 52px;
    bottom: 44px;
    left: 22px;
    font-size: clamp(0.62rem, 2.4vw, 0.76rem);
    line-height: 1.4;
  }

  .cert-corner {
    width: 36px;
    height: 36px;
  }

  .cert-body-block {
    gap: 3px;
    padding: 0 2% 0 3%;
    font-size: clamp(0.62rem, 2.8vw, 0.76rem);
    line-height: 1.45;
  }

  /* 窄屏仍单行：「被评为」+ 称号，避免多占垂直空间压住日期 */
  .cert-award-line {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.2em 0.35em;
  }

  .cert-honor {
    font-size: clamp(0.78rem, 3.4vw, 0.95rem);
    letter-spacing: 0.03em;
    text-align: center;
    line-height: 1.3;
  }

  .cert-closing {
    margin-top: 2px;
  }
}

.modal.show {
  display: grid;
}
