/* ==========================================================================
   NFC Profile Editor — Mobile-First Stylesheet (rebuild v1.4)
   ----------------------------------------------------------------------
   Principles
     • Mobile first. Base styles target 360px. Enhancements at min-width BPs.
     • 16px minimum input font-size → kills iOS auto-zoom on focus.
     • `touch-action: manipulation` on tappable elements → kills iOS
       double-tap-to-zoom on buttons.
     • 44×44 minimum hit area on all interactive controls (WCAG 2.5.5).
     • `dvh` for mobile-correct viewport height with vh fallback.
     • Pinch-to-zoom remains enabled (accessibility).
   ========================================================================== */

/* ---------------- Design tokens ---------------- */
:root {
  --nfce-primary: #dc2626;
  --nfce-primary-dark: #b91c1c;
  --nfce-primary-light: #ef4444;
  --nfce-primary-ghost: rgba(220, 38, 38, .10);

  --nfce-bg: #ffffff;
  --nfce-card: #ffffff;
  --nfce-card-alt: #fafbfc;

  --nfce-text: #111827;
  --nfce-text-soft: #6b7280;
  --nfce-text-mute: #9ca3af;
  --nfce-border: #e5e7eb;
  --nfce-border-soft: #f3f4f6;
  --nfce-border-strong: #d1d5db;
  --nfce-muted: #9ca3af;

  --nfce-success: #059669;
  --nfce-success-bg: #ecfdf5;
  --nfce-success-bd: #a7f3d0;
  --nfce-danger: #b91c1c;
  --nfce-danger-bg: #fef2f2;
  --nfce-danger-bd: #fecaca;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;

  --sh-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --sh-md: 0 4px 12px -2px rgba(15, 23, 42, .10), 0 2px 4px -2px rgba(15, 23, 42, .06);
  --sh-lg: 0 12px 32px -8px rgba(15, 23, 42, .18), 0 4px 8px -4px rgba(15, 23, 42, .08);
  --sh-brand: 0 8px 18px -8px rgba(220, 38, 38, .55);

  --ease: cubic-bezier(.4, .0, .2, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          "Apple Color Emoji", "Segoe UI Emoji", Arial, sans-serif;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --z-bar: 5;
  --z-fab: 50;
  --z-toast: 100;
  --z-overlay: 200;
}

/* ============================================================
   1. RESET (scoped) + TOUCH FIXES
   ============================================================ */
.nfc-editor-wrap,
.nfc-editor-wrap * {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
          text-size-adjust: 100%;
}

.nfc-editor-wrap button,
.nfc-editor-wrap a,
.nfc-editor-wrap label,
.nfc-editor-wrap input[type="radio"],
.nfc-editor-wrap input[type="checkbox"],
.nfc-editor-wrap [role="button"],
.nfc-editor-wrap .nfc-step,
.nfc-editor-wrap .nfc-theme,
.nfc-editor-wrap .nfc-preview-tool,
.nfc-editor-wrap .nfc-pwd-toggle {
  touch-action: manipulation;
}
.nfc-editor-wrap button { user-select: none; -webkit-user-select: none; }

/* ============================================================
   2. PAGE WRAPPER
   ============================================================ */
.nfc-editor-wrap {
  font-family: var(--font);
  color: var(--nfce-text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    max(var(--s-3), var(--safe-top))
    max(var(--s-3), var(--safe-right))
    calc(var(--s-3) + var(--safe-bottom))
    max(var(--s-3), var(--safe-left));
  background:
    radial-gradient(900px 320px at 50% -10%, rgba(220, 38, 38, .10) 0%, transparent 60%),
    var(--nfce-bg);
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 768px) { .nfc-editor-wrap { padding: var(--s-5); } }

/* ============================================================
   3. SHARED FORM PRIMITIVES
   ============================================================ */
.nfc-form { display: flex; flex-direction: column; gap: var(--s-4); }

.nfc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.nfc-field--full { grid-column: 1 / -1; }
.nfc-field > label {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-2);
  font-size: 13px; font-weight: 600; color: #374151; line-height: 1.3;
}

.nfc-input,
.nfc-textarea,
.nfc-field input[type="tel"],
.nfc-field input[type="text"],
.nfc-field input[type="url"],
.nfc-field input[type="email"],
.nfc-field input[type="password"],
.nfc-field input[type="search"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font: 400 16px/1.4 var(--font); /* 16px → no iOS zoom */
  color: var(--nfce-text);
  background: var(--nfce-card-alt);
  border: 1.5px solid var(--nfce-border);
  border-radius: var(--r-md);
  -webkit-appearance: none;
          appearance: none;
  transition:
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.nfc-textarea { min-height: 96px; resize: vertical; line-height: 1.5; }

.nfc-input:focus,
.nfc-textarea:focus,
.nfc-field input:focus {
  outline: none;
  border-color: var(--nfce-primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--nfce-primary-ghost);
}
.nfc-input::placeholder,
.nfc-textarea::placeholder { color: var(--nfce-text-mute); }

.nfc-hint { margin: 4px 0 0; font-size: 12px; color: var(--nfce-text-soft); line-height: 1.4; }
.nfc-counter { font-size: 12px; font-weight: 500; color: var(--nfce-text-soft); }

/* Password toggle */
.nfc-pwd { position: relative; }
.nfc-pwd input { padding-right: 48px; }
.nfc-pwd-toggle {
  position: absolute; top: 50%; right: 6px;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  background: transparent; border: 0;
  border-radius: var(--r-sm);
  font-size: 16px; cursor: pointer; opacity: .55;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nfc-pwd-toggle:hover { opacity: 1; background: var(--nfce-border-soft); }
.nfc-pwd-toggle:active { transform: translateY(-50%) scale(.94); }

/* ============================================================
   4. BUTTONS
   ============================================================ */
.nfc-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px;
  padding: 12px 18px;
  font: 600 15px/1 var(--font);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition:
    transform var(--dur-fast) var(--ease),
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    opacity var(--dur) var(--ease);
}
.nfc-btn:active { transform: scale(.97); }
.nfc-btn:disabled,
.nfc-btn[disabled] { opacity: .55; cursor: not-allowed; transform: none !important; }
.nfc-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--nfce-primary-ghost); }

.nfc-btn-block { width: 100%; }

.nfc-btn-primary {
  background: linear-gradient(135deg, var(--nfce-primary), var(--nfce-primary-light));
  color: #fff;
  box-shadow: var(--sh-brand);
}
.nfc-btn-primary:hover { box-shadow: 0 12px 24px -8px rgba(220, 38, 38, .6); }

.nfc-btn-secondary {
  background: #fff; color: #374151; border-color: var(--nfce-border);
}
.nfc-btn-secondary:hover { background: var(--nfce-border-soft); border-color: var(--nfce-border-strong); }

.nfc-btn-ghost {
  background: transparent; color: var(--nfce-text-soft); padding: 10px 12px;
}
.nfc-btn-ghost:hover { background: var(--nfce-border-soft); color: var(--nfce-text); }

.nfc-btn-icon {
  min-width: 44px; width: 44px; padding: 10px; font-size: 18px;
}

.nfc-spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: nfc-spin .7s linear infinite;
}
.nfc-btn.is-loading .nfc-btn-label { opacity: .55; }
.nfc-btn.is-loading .nfc-spinner { display: inline-block; }
@keyframes nfc-spin { to { transform: rotate(360deg); } }

/* ============================================================
   5. ALERTS / TOAST
   ============================================================ */
.nfc-alert {
  padding: 14px 16px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 500; line-height: 1.5;
}
.nfc-alert-error {
  background: var(--nfce-danger-bg); color: var(--nfce-danger);
  border: 1px solid var(--nfce-danger-bd);
}

.nfc-toast {
  position: fixed;
  top: calc(var(--s-3) + var(--safe-top));
  left: var(--s-3); right: var(--s-3);
  max-width: 560px; margin: 0 auto;
  z-index: var(--z-toast);
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--nfce-success-bg);
  color: var(--nfce-success);
  border: 1px solid var(--nfce-success-bd);
  box-shadow: var(--sh-md);
  font-weight: 600; font-size: 14px;
  display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
  animation: nfc-toast-in .35s var(--ease);
}
.nfc-toast a { color: inherit; text-decoration: underline; }
.nfc-toast.is-fading { opacity: 0; transition: opacity .4s; }
@keyframes nfc-toast-in {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ============================================================
   6. LOGIN + PROFILE-SELECT (centered card flow)
   ============================================================ */
.nfc-editor-card {
  max-width: 460px; margin: 0 auto;
  background: var(--nfce-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--nfce-border-soft);
  box-shadow: var(--sh-lg);
  padding: var(--s-5);
}
@media (min-width: 480px) { .nfc-editor-card { padding: var(--s-6); } }

.nfc-editor-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
}
.nfc-editor-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--nfce-primary), var(--nfce-primary-light));
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .04em;
  box-shadow: var(--sh-brand);
}
.nfc-editor-brand-text {
  font-weight: 700; font-size: 16px; line-height: 1.3; letter-spacing: -.01em;
}

/* Language picker on login / select pages */
.nfc-editor-lang {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.nfc-editor-title {
  margin: 0 0 6px;
  font-size: 20px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em;
}
.nfc-editor-sub {
  margin: 0 0 var(--s-5);
  font-size: 14px; color: var(--nfce-text-soft); line-height: 1.5;
}

.nfc-actions { display: flex; gap: var(--s-2); margin-top: var(--s-2); }
.nfc-actions .nfc-btn { flex: 1; min-width: 0; }
.nfc-actions .nfc-btn-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nfc-profile-list {
  list-style: none; margin: 6px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: var(--s-2);
}
.nfc-profile-item {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 60px; padding: 14px;
  border: 1.5px solid var(--nfce-border);
  border-radius: var(--r-md);
  background: var(--nfce-card-alt);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nfc-profile-item:hover,
.nfc-profile-item:focus-within { border-color: var(--nfce-primary); }
.nfc-profile-item:has(input:checked) { border-color: var(--nfce-primary); background: var(--nfce-primary-ghost); }
.nfc-profile-item input[type="radio"] {
  width: 20px; height: 20px; flex: 0 0 20px; accent-color: var(--nfce-primary);
}
.nfc-profile-name { font-weight: 600; color: var(--nfce-text); font-size: 15px; }
.nfc-profile-slug { font-size: 12px; color: var(--nfce-text-soft); margin-top: 2px; }

/* ============================================================
   7. EDITOR LAYOUT (--full variant)
   ============================================================ */
.nfc-editor-wrap--full {
  padding:
    var(--s-3)
    max(var(--s-2), var(--safe-right))
    calc(var(--s-3) + var(--safe-bottom))
    max(var(--s-2), var(--safe-left));
}
@media (min-width: 768px) { .nfc-editor-wrap--full { padding: var(--s-5); } }

.nfc-editor-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
  max-width: 1180px;
  margin: 0 auto;
}

.nfc-editor-card--form {
  max-width: none; margin: 0;
  padding: var(--s-4) var(--s-4) 0;
  border-radius: var(--r-lg);
}
@media (min-width: 480px) {
  .nfc-editor-card--form { padding: var(--s-5) var(--s-5) 0; }
}

/* ---------- Editor header ---------- */
.nfc-editor-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  padding-bottom: var(--s-3);
  margin-bottom: var(--s-3);
  border-bottom: 1px solid var(--nfce-border-soft);
  flex-wrap: wrap;
}
.nfc-editor-head-meta { flex: 1 1 100%; min-width: 0; }
@media (min-width: 560px) {
  .nfc-editor-head-meta { flex: 1 1 auto; }
}
.nfc-editor-head .nfc-editor-title {
  margin: 0 0 2px;
  font-size: 17px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (min-width: 640px) {
  .nfc-editor-head .nfc-editor-title { font-size: 19px; }
}
.nfc-editor-public {
  display: inline-block; max-width: 220px;
  font-size: 12px; font-weight: 600; color: var(--nfce-primary);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nfc-editor-public:hover { text-decoration: underline; }

.nfc-editor-head-actions {
  display: flex; gap: var(--s-2); align-items: center; flex-shrink: 0;
  width: 100%;
}
@media (min-width: 560px) {
  .nfc-editor-head-actions { width: auto; }
}
.nfc-editor-head-actions .nfc-btn {
  flex: 1; min-height: 44px; padding: 8px 12px; font-size: 14px;
  font-weight: 600;
}
@media (min-width: 560px) {
  .nfc-editor-head-actions .nfc-btn { flex: 0 0 auto; }
}
.nfc-editor-logout { margin: 0; flex: 1; }
@media (min-width: 560px) { .nfc-editor-logout { flex: 0 0 auto; } }
.nfc-editor-logout .nfc-btn { width: 100%; }

.nfc-only-wide { display: none; }
@media (min-width: 640px) {
  .nfc-only-wide { display: inline; margin-left: 4px; }
  .nfc-editor-head-actions .nfc-btn-icon { width: auto; padding: 10px 14px; }
}
@media (min-width: 1024px) {
  .nfc-head-preview { display: none; }
}

/* ---------- Language switcher ---------- */
.nfc-lang-switch {
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 10px center no-repeat;
  color: #1f2937;
  cursor: pointer;
  font-family: inherit;
  min-height: 44px;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.nfc-lang-switch:hover { border-color: #d1d5db; }
.nfc-lang-switch:focus-visible {
  outline: none;
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220,38,38,.12);
}
@media (min-width: 560px) {
  .nfc-lang-switch { width: auto; }
}

/* ---------- Language tabs (underline tabs) ---------- */
.nfc-lang-tabs {
  display: inline-flex;
  gap: 0;
  background: transparent;
  border-bottom: 2px solid var(--nfce-border);
  padding: 0;
  flex-shrink: 0;
}
.nfc-lang-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -2px;
  font: 600 13px/1 var(--font);
  color: var(--nfce-text-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
  touch-action: manipulation;
}
.nfc-lang-tab:hover {
  color: var(--nfce-text);
  border-bottom-color: var(--nfce-border-strong);
}
.nfc-lang-tab:active { color: var(--nfce-text); }
.nfc-lang-tab.is-active {
  background: transparent;
  color: var(--nfce-primary);
  border-bottom-color: var(--nfce-primary);
  box-shadow: none;
}
.nfc-lang-tab:focus-visible {
  outline: 2px solid var(--nfce-primary);
  outline-offset: -2px;
  border-radius: 4px 4px 0 0;
}
.nfc-lang-tab.is-active:focus-visible {
  outline: 2px solid var(--nfce-primary);
  outline-offset: -2px;
  box-shadow: none;
}

/* Language field groups */
.nfc-lang-fields {
  animation: nfc-fade .25s var(--ease);
}

/* On small screens, language tabs are compact */
@media (max-width: 559px) {
  .nfc-lang-tabs {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nfc-lang-tabs::-webkit-scrollbar { display: none; }
  .nfc-lang-tab {
    flex: 0 0 auto;
    justify-content: center;
    padding: 8px 12px;
    font-size: 13px;
    gap: 4px;
    min-height: 44px;
  }
}

/* Profile page variant — compact flag in top-bar */
.nfc-lang-switch--profile {
  padding: 4px 22px 4px 6px;
  font-size: 15px;
  font-weight: 600;
  min-height: auto;
  max-width: 50%;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: rgba(255,255,255,.10) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 5px center no-repeat;
  color: #ffffff;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  backdrop-filter: blur(6px);
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
  flex-shrink: 0;
  margin-left: auto;
  transition: background .15s ease;
}
.nfc-lang-switch--profile:hover {
  background-color: rgba(255,255,255,.18);
}
.nfc-lang-switch--profile:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,.35);
}
.nfc-lang-switch--profile option {
  color: #1f2937;
  background: #fff;
  font-size: 13px;
  text-shadow: none;
}
@media (max-width: 400px) {
  .nfc-lang-switch--profile {
    max-width: 44%;
    font-size: 13px;
    padding: 4px 18px 4px 4px;
    background-position: right 4px center;
  }
}

/* ---------- Avatar uploader ---------- */
.nfc-avatar-uploader {
  display: grid;
  grid-template-columns: 88px 1fr;
  align-items: center;
  gap: var(--s-3) var(--s-4);
  padding: var(--s-3);
  margin-bottom: var(--s-4);
  background: #fafafa;
  border: 1px solid var(--nfce-border-soft);
  border-radius: var(--r-lg);
}
@media (min-width: 480px) {
  .nfc-avatar-uploader { grid-template-columns: 104px 1fr; }
}
.nfc-avatar-preview {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: #e5e7eb center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; color: #9ca3af;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--nfce-border), 0 4px 10px rgba(0,0,0,.06);
  overflow: hidden;
}
@media (min-width: 480px) {
  .nfc-avatar-preview { width: 104px; height: 104px; font-size: 44px; }
}
.nfc-avatar-actions {
  grid-column: 2;
  display: flex; flex-wrap: wrap; gap: var(--s-2);
}
.nfc-avatar-pick { cursor: pointer; }
.nfc-avatar-pick.is-loading { opacity: .7; pointer-events: none; }
.nfc-avatar-uploader .nfc-hint {
  grid-column: 1 / -1; margin: 0;
  font-size: 12px; color: var(--nfce-text-mute);
}
.nfc-avatar-msg {
  grid-column: 1 / -1; margin: 0;
  font-size: 13px; min-height: 0;
}
.nfc-avatar-msg.is-error   { color: #b91c1c; }
.nfc-avatar-msg.is-success { color: #15803d; }

/* ============================================================
   8. STEPPER (horizontal scroll chips)
   ============================================================ */
.nfc-stepper {
  display: flex; gap: 6px;
  margin: 0 calc(var(--s-4) * -1) var(--s-4);
  padding: 0 var(--s-4) 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.nfc-stepper::-webkit-scrollbar { display: none; }

.nfc-step {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  background: transparent; border: 0;
  border-radius: var(--r-pill);
  font: 600 13px/1 var(--font);
  color: var(--nfce-text-soft);
  cursor: pointer; white-space: nowrap;
  scroll-snap-align: start;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.nfc-step > span {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 22px; width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--nfce-border); color: #6b7280;
  font-size: 12px; font-weight: 700;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nfc-step:hover { background: var(--nfce-border-soft); }
.nfc-step:active { transform: scale(.96); }
.nfc-step.is-active { color: var(--nfce-primary); background: var(--nfce-primary-ghost); }
.nfc-step.is-active > span { background: var(--nfce-primary); color: #fff; }
.nfc-step.is-done > span { background: var(--nfce-success); color: #fff; }

/* On smallest phones: number-only chips for inactive steps */
@media (max-width: 399px) {
  .nfc-step:not(.is-active) {
    font-size: 0;
    padding: 8px;
    min-width: 40px;
  }
  .nfc-step:not(.is-active) > span { margin: 0; }
}
@media (min-width: 768px) {
  .nfc-stepper {
    margin-left: 0; margin-right: 0;
    padding-left: 0; padding-right: 0;
    overflow: visible; flex-wrap: wrap;
  }
  .nfc-step { flex: 1 1 0; }
}

/* ============================================================
   9. STEP PANELS + GRID
   ============================================================ */
.nfc-step-panel { display: none; animation: nfc-fade var(--dur-slow) var(--ease); }
.nfc-step-panel.is-active { display: block; }
@keyframes nfc-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.nfc-step-title {
  margin: 0 0 var(--s-3);
  font-size: 15px; font-weight: 700; letter-spacing: -.005em;
}
@media (min-width: 640px) {
  .nfc-step-title { font-size: 16px; margin-bottom: var(--s-4); }
}

.nfc-grid {
  display: grid; grid-template-columns: 1fr; gap: var(--s-3);
}
@media (min-width: 560px) {
  .nfc-grid { grid-template-columns: 1fr 1fr; gap: var(--s-4); }
}

/* ============================================================
   10. THEME PICKER + PROFILE LINK
   ============================================================ */
/* Profile link card (Step 4) — stacked on mobile, row on tablet+ */
.nfc-profile-link-card {
  display: flex; flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  margin-bottom: var(--s-4);
  background: #fafafa;
  border: 1px solid var(--nfce-border-soft);
  border-radius: var(--r-md);
}
@media (min-width: 480px) {
  .nfc-profile-link-card {
    flex-direction: row; align-items: center; justify-content: space-between;
    gap: var(--s-3);
  }
}
.nfc-profile-link-card strong { font-size: 14px; display: block; }
.nfc-profile-link-card small  { font-size: 12px; color: var(--nfce-text-mute); }
.nfc-profile-link-card .nfc-btn {
  width: 100%; min-height: 40px; padding: 8px 16px;
  font-size: 14px; font-weight: 600;
}
@media (min-width: 480px) {
  .nfc-profile-link-card .nfc-btn { width: auto; flex-shrink: 0; }
}

.nfc-themes {
  display: grid; grid-template-columns: 1fr; gap: var(--s-2);
}
@media (min-width: 480px) {
  .nfc-themes { grid-template-columns: 1fr 1fr; gap: var(--s-3); }
}

.nfc-theme {
  position: relative;
  display: flex; align-items: center; gap: var(--s-2);
  min-height: 56px; padding: 10px 12px;
  background: var(--nfce-card-alt);
  border: 1.5px solid var(--nfce-border);
  border-radius: var(--r-md);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
@media (min-width: 480px) {
  .nfc-theme { gap: var(--s-3); min-height: 64px; padding: 12px; }
}
.nfc-theme:hover { transform: translateY(-1px); border-color: var(--nfce-border-strong); }
.nfc-theme:active { transform: scale(.98); }
.nfc-theme input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.nfc-theme.is-selected {
  border-color: var(--nfce-primary);
  background: var(--nfce-primary-ghost);
}
.nfc-theme-swatch {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .08), 0 4px 8px -2px rgba(0, 0, 0, .15);
}
.nfc-theme-meta {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.nfc-theme-meta strong {
  font-size: 13px; font-weight: 700; color: var(--nfce-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nfc-theme-meta small {
  font-size: 12px; color: var(--nfce-text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================
   11. STICKY ACTION BAR
   ============================================================ */
.nfc-actionbar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: var(--s-2);
  margin: var(--s-5) calc(var(--s-4) * -1) 0;
  padding:
    var(--s-3)
    var(--s-4)
    calc(var(--s-3) + var(--safe-bottom));
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-top: 1px solid var(--nfce-border-soft);
  z-index: var(--z-bar);
}
@media (min-width: 480px) {
  .nfc-actionbar {
    margin-left: calc(var(--s-5) * -1); margin-right: calc(var(--s-5) * -1);
    padding-left: var(--s-5); padding-right: var(--s-5);
  }
}

[data-nfc-prev],
[data-nfc-next] {
  flex: 0 0 auto;
  padding: 12px 14px;
  font-size: 14px;
}
[data-nfc-save] { flex: 1; margin-left: auto; min-width: 0; }
.nfc-dotbar { flex: 1; display: flex; justify-content: center; gap: 6px; }
.nfc-dotbar span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--nfce-border);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.nfc-dotbar span.is-active { background: var(--nfce-primary); transform: scale(1.3); }

/* ============================================================
   12. PREVIEW PANE
   Mobile = full-screen bottom sheet (slides up).
   Desktop ≥1024px = sticky sidebar.
   ============================================================ */
.nfc-preview-pane {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: linear-gradient(180deg, #111827, #0b1220);
  color: #fff;
  display: flex; flex-direction: column;
  padding:
    calc(var(--s-3) + var(--safe-top))
    var(--s-3)
    calc(var(--s-3) + var(--safe-bottom));
  transform: translateY(100%);
  visibility: hidden;
  transition: transform .32s var(--ease), visibility .32s linear;
}
.nfc-preview-pane.is-open {
  transform: translateY(0);
  visibility: visible;
}

.nfc-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  flex-shrink: 0;
}
.nfc-preview-label {
  font-size: 12px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  opacity: .85;
}
.nfc-preview-tools { display: flex; gap: 6px; align-items: center; }
.nfc-preview-tool {
  min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .10);
  color: #fff; border: 0;
  border-radius: 22px;
  font-size: 13px; font-weight: 600; line-height: 1;
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.nfc-preview-tool.nfc-preview-close {
  width: 36px; padding: 0;
  border-radius: 50%;
  font-size: 20px; font-weight: 400;
}
.nfc-preview-tool:hover { background: rgba(255, 255, 255, .20); }
.nfc-preview-tool:active { transform: scale(.92); }

.nfc-preview-frame {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  padding: var(--s-2) 0;
}

.nfc-preview-phone {
  position: relative;
  width: 100%;
  max-width: 380px;
  height: 100%;
  max-height: 760px;
  background: #000;
  border-radius: 32px;
  padding: 10px;
  box-shadow:
    0 20px 40px -10px rgba(0, 0, 0, .7),
    inset 0 0 0 1.5px rgba(255, 255, 255, .06);
  overflow: hidden;
}
.nfc-preview-phone iframe {
  width: 100%; height: 100%;
  border: 0;
  border-radius: 22px;
  background: #fff;
  display: block;
}
.nfc-preview-loading {
  position: absolute; inset: 10px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .88);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}

/* Desktop: preview becomes a sticky sidebar */
@media (min-width: 1024px) {
  .nfc-editor-layout {
    grid-template-columns: minmax(0, 1fr) 400px;
    align-items: start;
  }
  .nfc-preview-pane {
    position: sticky;
    inset: auto;
    top: var(--s-4);
    transform: none;
    visibility: visible;
    max-height: calc(100dvh - var(--s-7));
    border-radius: var(--r-lg);
    padding: var(--s-4);
    transition: none;
  }
  .nfc-preview-close { display: none; }
  .nfc-preview-phone { max-height: none; height: calc(100dvh - 140px); }
}

/* ============================================================
   13. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .nfc-editor-wrap *,
  .nfc-editor-wrap *::before,
  .nfc-editor-wrap *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================
   14. LOGO UPLOADER + MOBILE OVERFLOW GUARDS
   ============================================================ */
.nfc-logo-uploader {
  display: grid;
  grid-template-columns: 88px 1fr;
  align-items: center;
  gap: var(--s-3) var(--s-4);
  padding: var(--s-3);
  background: #fafafa;
  border: 1px solid var(--nfce-border-soft);
  border-radius: var(--r-lg);
}
@media (min-width: 480px) {
  .nfc-logo-uploader { grid-template-columns: 120px 1fr; }
}
.nfc-logo-preview {
  width: 88px; height: 88px;
  border-radius: var(--r-md);
  background: #fff center/contain no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #9ca3af;
  border: 1px solid var(--nfce-border);
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
  overflow: hidden;
}
@media (min-width: 480px) {
  .nfc-logo-preview { width: 120px; height: 88px; }
}
.nfc-logo-uploader .nfc-avatar-actions { grid-column: 2; }
.nfc-logo-uploader .nfc-hint,
.nfc-logo-uploader .nfc-avatar-msg { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--nfce-text-mute); }
.nfc-logo-uploader .nfc-avatar-msg.is-error   { color: #b91c1c; }
.nfc-logo-uploader .nfc-avatar-msg.is-success { color: #15803d; }

/* Mobile overflow guards: keep stepper content inside the card width */
.nfc-editor-wrap--full {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}
.nfc-editor-card--form {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.nfc-editor-layout { width: 100%; min-width: 0; }
.nfc-step-panel,
.nfc-step-panel .nfc-grid,
.nfc-step-panel .nfc-field,
.nfc-editor-head,
.nfc-editor-head-meta,
.nfc-editor-head-actions { min-width: 0; }
.nfc-step-panel .nfc-input,
.nfc-step-panel .nfc-textarea,
.nfc-step-panel select { max-width: 100%; }
/* Prevent long slugs / URLs in the header from pushing layout wider */
.nfc-editor-slug,
.nfc-editor-head a,
.nfc-editor-head code {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* iOS: prevent input zoom on focus by forcing 16px on ALL editor controls */
.nfc-editor-wrap--full input,
.nfc-editor-wrap--full select,
.nfc-editor-wrap--full textarea {
  font-size: 16px;
}

/* Keep single-row action bar on every screen size */
@media (max-width: 479px) {
  .nfc-actionbar {
    flex-wrap: nowrap;
    padding-left: var(--s-3);
    padding-right: var(--s-3);
    gap: 6px;
  }
  .nfc-actionbar .nfc-dotbar {
    flex: 1 1 auto;
    min-width: 0;
  }
  [data-nfc-prev],
  [data-nfc-next] {
    padding: 8px 11px;
    font-size: 13px;
    min-height: 38px;
    flex: 0 0 auto;
  }
  [data-nfc-save] {
    flex: 0 0 auto;
    margin-left: 0;
    padding: 8px 12px;
    font-size: 13px;
    min-height: 38px;
  }

  /* Compact stepper chips so all 4 fit without crop */
  .nfc-stepper {
    gap: 4px;
    margin-left: calc(var(--s-3) * -1);
    margin-right: calc(var(--s-3) * -1);
    padding-left: var(--s-3);
    padding-right: var(--s-3);
  }
  .nfc-step {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
    gap: 5px;
  }
  .nfc-step > span {
    flex: 0 0 18px; width: 18px; height: 18px;
    font-size: 10px;
  }
}

/* Even tighter on very narrow phones (<360px) */
@media (max-width: 359px) {
  .nfc-step { padding: 6px 7px; font-size: 11.5px; }
  .nfc-step > span { flex-basis: 16px; width: 16px; height: 16px; }
}
