:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --bg-card: #ffffff;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --text-main: #4b5563;
  --text-strong: #111827;
  --border-subtle: rgba(209, 213, 219, 1);
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
  --phone-scale: 1;
}

/* Teams dark theme: app chrome (tab bar, config, content area) follow theme */
body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #201f1f;
  --bg-card: #292828;
  --accent: #5b5fc7;
  --accent-soft: rgba(91, 95, 199, 0.15);
  --text-main: #b5b5b5;
  --text-strong: #ffffff;
  --border-subtle: rgba(255, 255, 255, 0.12);
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.3);
}

/* Debug panel dark-mode fixes:
 * many debug UI elements use hardcoded light colors; switch them to theme-based colors. */
body[data-theme="dark"] .meta-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
body[data-theme="dark"] .meta-label {
  color: rgba(229, 231, 235, 0.85);
}
body[data-theme="dark"] .right-panel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
body[data-theme="dark"] .right-body {
  color: rgba(229, 231, 235, 0.85);
}
/* Card area stays white even in Teams dark mode, so QR subtext should stay dark. */
body[data-theme="dark"] .card-screen .qr-label {
  color: #374151;
}

/* Minimal design uses a dark pill behind QR subtext; keep text light always. */
.card-screen[data-card-format="minimal"] .qr-label {
  color: #ffffff;
}
body[data-theme="dark"] .card-screen[data-card-format="minimal"] .qr-label {
  color: #ffffff;
}
body[data-theme="dark"] .small-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(229, 231, 235, 0.9);
}

/*
 * Phone frame and card screen: always light theme (mobile and desktop).
 * Override variables so the digital business card area is not affected by Teams theme.
 */
.phone-frame {
  --bg: #f3f4f6;
  --bg-card: #ffffff;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --text-main: #4b5563;
  --text-strong: #111827;
  --border-subtle: rgba(209, 213, 219, 1);
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  background: var(--bg);
  color: var(--text-main);
  overflow: hidden;
}

.app-root {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.not-in-teams-message {
  display: none;
  min-height: 100vh;
  width: 100%;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  color: #4b5563;
}

.tab-content-area {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0;
  width: 100%;
  background: var(--bg-card);
}

/* iPhone-style frame on desktop */
.phone-frame {
  min-height: 100%;
  width: 100%;
  margin: 0 auto;
  background: var(--bg-card);
}

@media (min-width: 601px) {
  /* Card tab: gradient background matching theme (desktop only) */
  .tab-panel[data-tab-panel="card"].tab-content-area {
    background: linear-gradient(165deg, #e5e7eb 0%, #f3f4f6 40%, #eef0f3 100%);
  }
  body[data-theme="dark"] .tab-panel[data-tab-panel="card"].tab-content-area {
    background: linear-gradient(165deg, #2a2a2c 0%, #201f1f 40%, #252428 100%);
  }

  .tab-content-area {
    padding: 24px 16px 32px;
  }
  .phone-frame {
    max-width: 390px;
    min-height: 640px;
    border-radius: 54px;
    border: 10px solid #1c1c1e;
    box-shadow:
      0 0 0 2px #2c2c2e,
      0 20px 40px rgba(0, 0, 0, 0.12),
      0 40px 80px rgba(0, 0, 0, 0.18),
      0 60px 120px rgba(0, 0, 0, 0.1),
      inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    padding-top: 24px;
    transform-origin: center center;
    transform: scale(var(--phone-scale));
  }
  .phone-frame::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 126px;
    height: 34px;
    background: #1c1c1e;
    border-radius: 0 0 20px 20px;
    z-index: 1;
    pointer-events: none;
  }

  /* Dark mode: make phone frame stand out with gradient glow, visible border, and bigger shadow */
  body[data-theme="dark"] .phone-frame {
    border-color: #4a4a4a;
    box-shadow:
      0 0 0 2px rgba(91, 95, 199, 0.35),
      0 0 28px rgba(91, 95, 199, 0.18),
      0 0 56px rgba(0, 0, 0, 0.4),
      0 24px 48px rgba(0, 0, 0, 0.4),
      0 48px 96px rgba(0, 0, 0, 0.5),
      0 72px 144px rgba(0, 0, 0, 0.35),
      inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
  body[data-theme="dark"] .phone-frame::before {
    background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

/* In modern design, fill the phone interior top area with the same background color */
.phone-frame[data-card-format="modern"] {
  background: #354288;
}

.card-screen {
  min-height: 100%;
  width: 100%;
  padding-top: 14px;
  padding-bottom: 20px;
  padding-left: 20px;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  box-sizing: border-box;
}

.profile-panel {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  width: 100%;
  max-width: 380px;
}

/* Center panel content (and thus QR) horizontally in all card designs */
.card-screen .profile-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 0;
  padding-right: 0;
  box-sizing: border-box;
}

.profile-panel.settings-panel {
  max-width: none;
  padding: 24px 20px 32px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 3px solid rgba(148, 163, 184, 0.4);
  border-top-color: #2563eb;
  animation: loading-spin 0.9s linear infinite;
}

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

/* While loading, hide QR + profile content but keep phone frame size */
.card-screen.is-loading > .qr-wrapper,
.card-screen.is-loading > .profile-panel,
.card-screen.is-loading > .modern-card {
  visibility: hidden;
}

/* Modern design: base layout is hidden by default; shown when selected */
.modern-card {
  display: none;
  width: 100%;
  max-width: 380px;
  padding: 0 4px;
  box-sizing: border-box;
}

.card-screen[data-card-format="modern"] {
  /* Top portion colored; QR area visually separated with white card */
  background: #354288;
}

.card-screen[data-card-format="modern"] .modern-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-screen[data-card-format="modern"] .modern-card,
.card-screen[data-card-format="modern"] .modern-card * {
  color: #ffffff;
}

.card-screen[data-card-format="modern"] .profile-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-screen[data-card-format="modern"] .business-card-block,
.card-screen[data-card-format="modern"] .business-card-block * {
  color: #ffffff;
  border-top-color: rgba(255, 255, 255, 0.4);
}

.card-screen[data-card-format="modern"] .business-card-block {
  width: 100%;
  margin-top: 12px;
  padding-top: 12px;
}

.card-screen[data-card-format="modern"] .business-card-details .business-card-label {
  color: rgba(226, 232, 240, 0.9);
}

/* Reorder: details between display name and QR on modern */
.card-screen[data-card-format="modern"] .business-card-block {
  order: 2;
}

.card-screen[data-card-format="modern"] .qr-wrapper {
  order: 3;
  width: 100%;
  margin-top: 16px;
  margin-left: 0;
  margin-right: 0;
  padding-top: 16px;
  padding-bottom: 12px;
  padding-left: 12px;
  padding-right: 12px;
  box-sizing: border-box;
  background: #ffffff;
  border-radius: 16px;
}

.card-screen[data-card-format="modern"] .qr-label {
  color: #6b7280;
}

.modern-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.modern-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: contain;
}

.modern-company {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-strong);
  text-align: center;
}

.modern-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modern-main-left {
  flex: 1;
  min-width: 0;
}

.modern-display-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-strong);
  /* Allow wrapping within the layout on modern design */
  white-space: normal;
  overflow-wrap: break-word;
}

.modern-job-title {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(226, 232, 240, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modern-main-right {
  flex-shrink: 0;
}

.modern-avatar {
  width: 64px;
  height: 64px;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4),
    0 8px 20px rgba(0, 0, 0, 0.35);
}

.modern-avatar #avatarInitials {
  font-size: 24px;
}

/* On modern design, hide the second (standard) display name row to avoid duplication/extra line break */
.card-screen[data-card-format="modern"] .business-card-line--name {
  display: none;
}

/* On modern design, hide duplicate Title and Company rows from the details block */
.card-screen[data-card-format="modern"] [data-i18n="labelJobTitle"],
.card-screen[data-card-format="modern"] #jobTitle,
.card-screen[data-card-format="modern"] [data-i18n="labelCompanyName"],
.card-screen[data-card-format="modern"] #companyName {
  display: none;
}

/* On modern design, remove portrait photo and let name/title use full width */
.card-screen[data-card-format="modern"] .modern-main-right {
  display: none;
}

.card-screen[data-card-format="modern"] .modern-main-left {
  flex: 1;
  min-width: 0;
}

/* On modern design, ensure Mobile phone row is visible on mobile */
.card-screen[data-card-format="modern"] .business-card-line--mobile {
  display: contents !important;
}

.business-card-block {
  width: 100%;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

/* Name row: value only, no label; centered */
.business-card-line--name {
  margin-bottom: 14px;
  text-align: center;
}

.business-card-line--name .business-card-value--name {
  display: block;
  width: 100%;
  text-align: center;
}

/* Detail rows: table-like layout (labels and values in aligned columns) */
.business-card-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  align-items: baseline;
}

.business-card-details .business-card-line {
  display: contents;
}

.business-card-details .business-card-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  white-space: nowrap;
  padding-right: 4px;
}

.business-card-details .business-card-value {
  font-size: 16px;
  color: var(--text-strong);
  min-width: 0;
}

.business-card-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
}

.business-card-value {
  font-size: 16px;
  color: var(--text-strong);
}

.business-card-value--name {
  font-size: 24px;
  font-weight: 700;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #2563eb, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #eff6ff;
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(191, 219, 254, 1),
    0 10px 26px rgba(15, 23, 42, 0.18);
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: none;
}

.display-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-strong);
}

.mail {
  font-size: 13px;
  color: #6b7280;
  margin-top: 2px;
}

.job-title {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.meta-card {
  background: #f9fafb;
  border-radius: 10px;
  padding: 9px 9px 8px;
  border: 1px solid rgba(209, 213, 219, 1);
}

.meta-card--full {
  grid-column: 1 / -1;
}

.meta-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ca3af;
}

.meta-value {
  font-size: 12px;
  margin-top: 4px;
  color: var(--text-strong);
}

.button-secondary {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-strong);
  cursor: pointer;
}
.button-secondary:hover:not(:disabled) {
  background: var(--accent-soft);
}
.button-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.right-panel {
  background: #f9fafb;
  border-radius: 16px;
  padding: 16px 16px 14px;
  border: 1px solid rgba(209, 213, 219, 1);
}

.right-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
}

.right-body {
  margin-top: 10px;
  font-size: 12px;
  color: #6b7280;
}

.log {
  margin-top: 12px;
  padding: 8px 9px;
  border-radius: 10px;
  background: #0b1120;
  border: 1px solid #020617;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
}

.log--vpc {
  max-height: 220px;
  color: #94a3b8;
}

.log--vpc-compact {
  max-height: 72px;
  margin-top: 6px;
  padding: 4px 6px;
  font-size: 9px;
  line-height: 1.25;
}

.meta-value--compact {
  font-size: 11px;
  word-break: break-word;
}

.catalog-table-wrapper {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-card);
}

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.catalog-table th,
.catalog-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.catalog-table th {
  font-weight: 600;
  color: var(--text-strong);
  background: var(--accent-soft);
}
.catalog-table tbody tr:last-child td {
  border-bottom: none;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.small-pill {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(209, 213, 219, 1);
  font-size: 10px;
  color: #4b5563;
  background: #f9fafb;
}

.qr-wrapper {
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
  padding-top: 0;
  padding-bottom: 12px;
  padding-left: 12px;
  padding-right: 12px;
  border-top: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow: visible;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.qr-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #374151;
}

/* QR container: constrained so it never overflows; centered in all designs */
#qrCode {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  min-width: 0;
  overflow: visible;
  box-sizing: border-box;
  /* Scale display to 90% outside of QR package to avoid package sizing intervals */
  transform: scale(0.9);
  transform-origin: center center;
}

/* Center whatever the QR library injects (canvas/svg wrapper) */
#qrCode > * {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Force SVG to scale to container so full QR is always visible (overrides library inline size) */
#qrCode svg {
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 600px) {
  /* Extra safe room so QR is never cut off; symmetric horizontal padding */
  .card-screen {
    padding-left: 16px;
    padding-right: 16px;
    padding-top: 16px;
    padding-bottom: 20px;
  }

  /* Standard: make labels/values fit without needing extra scroll */
  .card-screen[data-card-format="standard"] .business-card-line--name {
    margin-bottom: 10px;
  }
  .card-screen[data-card-format="standard"] .business-card-block {
    margin-top: 10px;
    padding-top: 10px;
  }
  .card-screen[data-card-format="standard"] .business-card-details {
    gap: 6px 10px;
  }
  .card-screen[data-card-format="standard"] .business-card-details .business-card-label {
    font-size: 11px;
  }
  .card-screen[data-card-format="standard"] .business-card-details .business-card-value {
    font-size: 14px;
  }
  .profile-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
  }
  .qr-wrapper {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 16px;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
  }
  /* QR container: fit inside horizontal safe area so edges are never cut off; true center */
  #qrCode {
    width: 100%;
    max-width: calc(100vw - 32px); /* 16px safe padding on each side */
    margin: 0 auto;
    padding: 0;
  }
  #qrCode svg {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    margin: 0 auto;
    display: block;
  }
}

.tab-bar {
  display: flex;
  flex-shrink: 0;
  width: 100%;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card);
  padding: 0 8px;
}

.tab-bar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  margin: 0 4px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.tab-bar-button:hover {
  color: var(--text-strong);
}

.tab-bar-button[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: auto;
}

.tab-panel[aria-hidden="false"] {
  display: flex;
}

/* Card tab: on desktop, phone + config side by side; on mobile, phone only */
.card-tab-desktop-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100%;
  align-items: center;
}

@media (min-width: 601px) {
  .card-tab-desktop-layout {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 16px;
  }
}

/* Configuration menu: desktop only, outside phone frame */
.card-tab-config {
  display: none;
}

@media (min-width: 601px) {
  .card-tab-config {
    display: block;
    flex-shrink: 0;
  }
}

@media (max-width: 600px) {
  .card-tab-config {
    display: none !important;
  }
  .tab-bar {
    display: none !important;
  }
  .tab-panel[data-tab-panel="card"] {
    display: flex !important;
  }
  .tab-panel[data-tab-panel="debug"] {
    display: none !important;
  }

  /* Mobile: show preferences as a centered modal */
  #panel-card.mobile-config-open {
    overflow: hidden;
  }

  #panel-card.mobile-config-open .card-tab-config {
    display: flex !important;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    padding: 18px;
    z-index: 9999;
  }

  #panel-card.mobile-config-open .config-panel {
    max-width: 360px;
    width: 100%;
    max-height: 85vh;
    overflow: auto;
  }

  #panel-card.mobile-config-open .mobile-config-close-btn {
    display: inline-flex;
  }
}

/* Portrait-only guard on mobile.
 * Note: Browsers generally cannot fully "prevent rotation" in webviews,
 * but we can block interaction when the device is in landscape. */
.portrait-only-overlay {
  display: none;
}

@media (max-width: 600px) and (orientation: landscape) {
  .portrait-only-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: var(--text-strong);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    font-weight: 700;
  }

  .app-root {
    pointer-events: none;
  }

  /* Mobile Teams fallback:
   * Instead of blocking, counter-rotate to keep the portrait-style UI visible. */
  body[data-force-portrait="true"] .portrait-only-overlay {
    display: none;
  }

  body[data-force-portrait="true"] .app-root {
    pointer-events: auto;
  }

  body[data-force-portrait="true"] .tab-panel[data-tab-panel="card"] {
    overflow: hidden;
  }

  body[data-force-portrait="true"] .phone-frame {
    width: 100vh;
    height: 100vw;
    min-height: 0;
    transform: rotate(-90deg);
    transform-origin: center center;
  }
}

/* Teams mobile webview: treat as mobile layout even when the container width
 * is larger than our CSS breakpoint. */
body[data-force-mobile="true"] .card-tab-config {
  display: none !important;
}
body[data-force-mobile="true"] .tab-bar {
  display: none !important;
}
body[data-force-mobile="true"] .tab-panel[data-tab-panel="card"] {
  display: flex !important;
}
body[data-force-mobile="true"] .tab-panel[data-tab-panel="debug"] {
  display: none !important;
}

body[data-force-mobile="true"] .card-screen {
  padding-left: 16px;
  padding-right: 16px;
  padding-top: 16px;
  padding-bottom: 20px;
}

body[data-force-mobile="true"] .card-screen[data-card-format="standard"] .business-card-line--name {
  margin-bottom: 10px;
}
body[data-force-mobile="true"] .card-screen[data-card-format="standard"] .business-card-block {
  margin-top: 10px;
  padding-top: 10px;
}
body[data-force-mobile="true"] .card-screen[data-card-format="standard"] .business-card-details {
  gap: 6px 10px;
}
body[data-force-mobile="true"] .card-screen[data-card-format="standard"] .business-card-details .business-card-label {
  font-size: 11px;
}
body[data-force-mobile="true"] .card-screen[data-card-format="standard"] .business-card-details .business-card-value {
  font-size: 14px;
}

body[data-force-mobile="true"] .profile-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
}

body[data-force-mobile="true"] .qr-wrapper {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 16px;
  padding-left: 12px;
  padding-right: 12px;
  box-sizing: border-box;
}

body[data-force-mobile="true"] #qrCode {
  width: 100%;
  max-width: calc(100vw - 32px);
  margin: 0 auto;
  padding: 0;
}
body[data-force-mobile="true"] #qrCode svg {
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  margin: 0 auto;
  display: block;
}

body[data-force-mobile="true"] #panel-card.mobile-config-open {
  overflow: hidden;
}
body[data-force-mobile="true"] #panel-card.mobile-config-open .card-tab-config {
  display: flex !important;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 18px;
  z-index: 9999;
}
body[data-force-mobile="true"] #panel-card.mobile-config-open .config-panel {
  max-width: 360px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
}
body[data-force-mobile="true"] #panel-card.mobile-config-open .mobile-config-close-btn {
  display: inline-flex;
}

/* iPhone Teams client tuning:
 * prioritize larger text to reduce unused vertical screen estate. */
body[data-force-mobile="true"][data-ios-client="true"] .business-card-line--name .business-card-value--name {
  font-size: 28px;
}
body[data-force-mobile="true"][data-ios-client="true"] .business-card-details .business-card-label {
  font-size: 12px;
}
body[data-force-mobile="true"][data-ios-client="true"] .business-card-details .business-card-value {
  font-size: 16px;
  line-height: 1.2;
}

/* Standard-specific iPhone boost */
body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="standard"] .business-card-block {
  margin-top: 12px;
  padding-top: 12px;
}
body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="standard"] .business-card-details {
  gap: 8px 12px;
}

/* Minimal-specific iPhone boost */
body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="minimal"] #jobTitle {
  font-size: 16px;
}
body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="minimal"] #companyName {
  font-size: 16px;
}
body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="minimal"] #userPrincipalName,
body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="minimal"] #mobilePhone {
  font-size: 15px;
}

.config-panel {
  min-width: 220px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  position: relative;
}

.config-panel h3 {
  margin: 0 0 10px 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
}

.config-row {
  margin-bottom: 10px;
}

.config-row:last-child {
  margin-bottom: 0;
}

.config-row label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.config-row select {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-strong);
}

.config-save-btn {
  width: 100%;
  margin-top: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.config-save-btn:hover {
  background: #1d4ed8;
}

.config-save-btn:active {
  transform: scale(0.98);
}

.mobile-config-close-btn {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-strong);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mobile-config-close-btn:active {
  transform: scale(0.98);
}

/* ── Minimal card format ──────────────────────────────────────────────────── */
.card-screen[data-card-format="minimal"] {
  justify-content: center;
}

.card-screen[data-card-format="minimal"] .modern-card {
  display: none;
}

.card-screen[data-card-format="minimal"] .qr-wrapper {
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 12px;
}

.card-screen[data-card-format="minimal"] .qr-label {
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #111827;
  color: #f9fafb;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-screen[data-card-format="minimal"] .business-card-block {
  border-top: none;
  margin-top: 8px;
  padding-top: 0;
  text-align: center;
}

.card-screen[data-card-format="minimal"] .business-card-line--name {
  margin-bottom: 2px;
}

.card-screen[data-card-format="minimal"] .business-card-value--name {
  font-size: 26px;
  font-weight: 700;
}

.card-screen[data-card-format="minimal"] .business-card-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.card-screen[data-card-format="minimal"] .business-card-details .business-card-line {
  display: block;
  text-align: center;
}

/* Hide Department value entirely on minimal */
.card-screen[data-card-format="minimal"] #department {
  display: none;
}

/* Remove Title label on minimal but keep value, shown under name */
.card-screen[data-card-format="minimal"] [data-i18n="labelJobTitle"] {
  display: none;
}

.card-screen[data-card-format="minimal"] #jobTitle {
  display: block;
  font-size: 15px;
  font-weight: 400;
  text-align: center;
  margin-top: 0;
}

/* Company row: company name centered with inline logo (no border/background) */
.card-screen[data-card-format="minimal"] #companyName {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  color: #4b5563;
  margin-top: 4px;
}

.card-screen[data-card-format="minimal"] #companyName::before {
  content: "";
  width: 20px;
  height: 20px;
  background: url("/logo.png") center/contain no-repeat;
}

/* Email + Mobile: icon on the left, value centered */
.card-screen[data-card-format="minimal"] [data-i18n="labelEmail"],
.card-screen[data-card-format="minimal"] [data-i18n="labelMobile"],
/* Remove Department + Company labels (keep only values) */
.card-screen[data-card-format="minimal"] [data-i18n="labelDepartment"],
.card-screen[data-card-format="minimal"] [data-i18n="labelCompanyName"] {
  display: none;
}

.card-screen[data-card-format="minimal"] #userPrincipalName,
.card-screen[data-card-format="minimal"] #mobilePhone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #4b5563;
}

.card-screen[data-card-format="minimal"] #userPrincipalName::before,
.card-screen[data-card-format="minimal"] #mobilePhone::before {
  display: inline-block;
  margin-right: 6px;
  font-size: 15px;
}

.card-screen[data-card-format="minimal"] #userPrincipalName::before {
  content: "✉";
}

.card-screen[data-card-format="minimal"] #mobilePhone::before {
  content: "☎";
}

/* iPhone hard override: keep text visually larger so card content
 * uses available vertical space better on iOS Teams webview. */
body[data-force-mobile="true"][data-ios-client="true"] .card-screen {
  padding-top: 12px !important;
  padding-bottom: 12px !important;
}

body[data-force-mobile="true"][data-ios-client="true"] .business-card-line--name {
  margin-bottom: 10px !important;
}
body[data-force-mobile="true"][data-ios-client="true"] .business-card-line--name .business-card-value--name {
  font-size: 32px !important;
}

body[data-force-mobile="true"][data-ios-client="true"] .business-card-block {
  margin-top: 10px !important;
  padding-top: 10px !important;
}
body[data-force-mobile="true"][data-ios-client="true"] .business-card-details {
  gap: 8px 12px !important;
}
body[data-force-mobile="true"][data-ios-client="true"] .business-card-details .business-card-label {
  font-size: 12px !important;
}
body[data-force-mobile="true"][data-ios-client="true"] .business-card-details .business-card-value {
  font-size: 18px !important;
  line-height: 1.22 !important;
}

body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="minimal"] #jobTitle {
  font-size: 18px !important;
}
body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="minimal"] #companyName {
  font-size: 18px !important;
}
body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="minimal"] #userPrincipalName,
body[data-force-mobile="true"][data-ios-client="true"] .card-screen[data-card-format="minimal"] #mobilePhone {
  font-size: 17px !important;
}
