:root {
  --bg-page: #060a14;
  --bg-dark-top: #0a1224;
  --bg-dark-bot: #0f1b33;
  --tradicia-blue: #0055b8;
  --tradicia-blue-hi: #2578e8;
  --tradicia-blue-hover: #004496;
  --ink-light: #f8fafc;
  --ink-muted: #b6c5dd;
  --ink-dark: #0f172a;
  --ink-sub: #334155;
  --surface-white: #ffffff;
  --dock-bg: #f1f5fa;
  --dock-border: #e1e9f3;
  --dock-hover: #e5eef9;
  --radius-card: 26px;
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-page);
  color: var(--ink-dark);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background:
    radial-gradient(640px 420px at 50% 0%, rgba(0, 85, 184, 0.24), transparent 70%),
    radial-gradient(520px 360px at 50% 100%, rgba(15, 36, 74, 0.35), transparent 72%),
    var(--bg-page);
}

.card-shell {
  width: 100%;
  max-width: 412px;
  margin: 0 auto;
}

.vcard {
  width: 100%;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface-white);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.56),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
}

/* ── Top Dark Identity Zone ── */
.vc-night {
  position: relative;
  overflow: hidden;
  padding: 20px 22px 22px;
  background:
    radial-gradient(280px 180px at 14% 0%, rgba(37, 120, 232, 0.28), transparent 70%),
    linear-gradient(160deg, var(--bg-dark-top) 0%, var(--bg-dark-bot) 100%);
  color: var(--ink-light);
}

.vc-watermark {
  position: absolute;
  right: -20px;
  bottom: -24px;
  width: 148px;
  height: 140px;
  color: #ffffff;
  opacity: 0.045;
  pointer-events: none;
  user-select: none;
}

.vc-watermark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.vc-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.vc-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: #ffffff;
}

.vc-logo-full {
  display: inline-flex;
  align-items: center;
  height: 26px;
}

.vc-logo-full svg {
  height: 26px;
  width: auto;
  display: block;
}

.vc-emblem {
  display: inline-flex;
  align-items: center;
  width: 22px;
  height: 21px;
  flex-shrink: 0;
  color: #ffffff;
}

.vc-emblem svg {
  width: 100%;
  height: 100%;
  display: block;
}

.vc-brand-word {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #eaf2ff;
  white-space: nowrap;
}

.vc-lang {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  flex-shrink: 0;
}

.vc-lang button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #b8c8e2;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  padding: 6px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.vc-lang button:hover {
  color: #ffffff;
}

.vc-lang button.active {
  background: #ffffff;
  color: #091122;
}

.vc-identity {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
}

.vc-avatar-wrap {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  flex-shrink: 0;
  padding: 2px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.42), rgba(37, 120, 232, 0.55));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.38);
}

.vc-photo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  display: block;
  background: #13213c;
}

.vc-meta {
  min-width: 0;
  flex: 1;
}

.vc-name {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.16;
  letter-spacing: -0.02em;
  color: var(--ink-light);
  overflow-wrap: break-word;
}

.vc-role {
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.32;
  color: var(--ink-muted);
  overflow-wrap: break-word;
}

/* ── Signature Tradicia Blue Seam ── */
.vc-seam {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, #004394 0%, #0066d6 50%, #3b95ff 100%);
  flex-shrink: 0;
}

/* ── Pure White Daylight QR & Action Stage ── */
.vc-day {
  background: var(--surface-white);
  padding: 22px 22px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.vc-qr-stage {
  position: relative;
  padding: 12px;
  background: #ffffff;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Subtle architectural corner ticks using pure CSS borders (no SVG strokes) */
.vc-qr-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: rgba(0, 85, 184, 0.42);
  border-style: solid;
  pointer-events: none;
}

.vc-qr-corner.tl { top: 0; left: 0; border-width: 2px 0 0 2px; border-top-left-radius: 6px; }
.vc-qr-corner.tr { top: 0; right: 0; border-width: 2px 2px 0 0; border-top-right-radius: 6px; }
.vc-qr-corner.bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; border-bottom-left-radius: 6px; }
.vc-qr-corner.br { bottom: 0; right: 0; border-width: 0 2px 2px 0; border-bottom-right-radius: 6px; }

.vc-qr-plate {
  width: 232px;
  height: 232px;
  color: #0b1120;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vc-qr-plate svg {
  width: 100%;
  height: 100%;
  display: block;
}

.vc-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vc-save-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, #0b63ca 0%, var(--tradicia-blue) 100%);
  color: #ffffff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 20px rgba(0, 85, 184, 0.28);
  transition: transform 0.14s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.vc-save-btn:hover {
  background: var(--tradicia-blue-hover);
  box-shadow: 0 10px 24px rgba(0, 68, 150, 0.34);
}

.vc-save-btn:active {
  transform: scale(0.985);
}

.vc-save-btn svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  display: block;
}

.vc-dock {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--ch-cols, 5), minmax(0, 1fr));
  gap: 8px;
}

.vc-ch {
  appearance: none;
  border: 1px solid var(--dock-border);
  background: var(--dock-bg);
  color: var(--ink-dark);
  border-radius: 14px;
  padding: 10px 4px 9px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  min-width: 0;
  font-family: var(--font-sans);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.vc-ch:hover {
  background: var(--dock-hover);
  border-color: rgba(0, 85, 184, 0.34);
  color: var(--tradicia-blue);
}

.vc-ch:active {
  transform: scale(0.96);
}

.vc-ch svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

.vc-ch span {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Toast notification ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  background: rgba(9, 17, 34, 0.94);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: calc(100vw - 32px);
  text-align: center;
}

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

/* ── Mobile 390px refinements ── */
@media (max-width: 440px) {
  body {
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  }

  .vcard {
    border-radius: 24px;
  }

  .vc-night {
    padding: 18px 18px 20px;
  }

  .vc-top {
    margin-bottom: 18px;
  }

  .vc-avatar-wrap {
    width: 78px;
    height: 78px;
  }

  .vc-name {
    font-size: 20.5px;
  }

  .vc-role {
    font-size: 13px;
  }

  .vc-day {
    padding: 20px 18px 20px;
    gap: 16px;
  }

  .vc-qr-plate {
    width: 220px;
    height: 220px;
  }

  .vc-dock {
    gap: 6px;
  }

  .vc-ch {
    padding: 9px 2px 8px;
  }

  .vc-ch span {
    font-size: 9.5px;
    letter-spacing: -0.02em;
  }
}

/* ── Compact Mobile 320px refinements ── */
@media (max-width: 350px) {
  body {
    padding: 8px;
  }

  .vcard {
    border-radius: 20px;
  }

  .vc-night {
    padding: 14px 14px 16px;
  }

  .vc-top {
    margin-bottom: 14px;
    gap: 8px;
  }

  .vc-logo-full,
  .vc-logo-full svg {
    height: 22px;
  }

  .vc-brand-word {
    font-size: 10.5px;
  }

  .vc-lang button {
    font-size: 10px;
    padding: 5px 7px;
  }

  .vc-identity {
    gap: 12px;
  }

  .vc-avatar-wrap {
    width: 68px;
    height: 68px;
  }

  .vc-name {
    font-size: 18px;
    margin-bottom: 4px;
  }

  .vc-role {
    font-size: 12px;
  }

  .vc-day {
    padding: 16px 14px 16px;
    gap: 14px;
  }

  .vc-qr-stage {
    padding: 10px;
  }

  .vc-qr-plate {
    width: 204px;
    height: 204px;
  }

  .vc-save-btn {
    min-height: 44px;
    font-size: 14px;
  }

  .vc-dock {
    gap: 4px;
  }

  .vc-ch {
    padding: 8px 1px 7px;
    border-radius: 11px;
  }

  .vc-ch svg {
    width: 17px;
    height: 17px;
  }

  .vc-ch span {
    font-size: 8.5px;
    letter-spacing: -0.03em;
  }
}

/* ── Automatic Mobile Landscape Adaptation ── */
@media (orientation: landscape) and (max-height: 560px) and (min-width: 560px) {
  .card-shell {
    max-width: 720px;
  }

  .vcard {
    display: grid;
    grid-template-columns: 1.06fr 3px 0.94fr;
    align-items: stretch;
  }

  .vc-night {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 22px;
  }

  .vc-seam {
    width: 3px;
    height: auto;
    background: linear-gradient(180deg, #004394 0%, #0066d6 50%, #3b95ff 100%);
  }

  .vc-day {
    justify-content: center;
    padding: 18px 20px;
    gap: 14px;
  }

  .vc-qr-plate {
    width: 196px;
    height: 196px;
  }
}
